package com.qeegoo.b2bautozityp.injector.module;

import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;

import com.qeegoo.b2bautozityp.api.RequestApi;
import com.qeegoo.b2bautozityp.injector.PerActivity;
import com.qeegoo.b2bautozityp.moudle.base.AppBar;
import com.qeegoo.b2bautozityp.moudle.base.FragmentPagerAdapter;
import com.qeegoo.b2bautozityp.moudle.good.viewmodel.GoodsViewModel;
import com.qeegoo.b2bautozityp.moudle.good.viewmodel.category.GoodsCategorySearchViewModel;
import com.qeegoo.b2bautozityp.moudle.good.viewmodel.category.GoodsCategoryViewModel;
import com.qeegoo.b2bautozityp.rxbus.RxBus;

import java.util.ArrayList;

import dagger.Module;
import dagger.Provides;

/**
 * 王少岩 在 2017/9/13 创建了它
 */

@Module
public class GoodsActivityModule {

    @Provides
    @PerActivity
    AppBar provideAppBar() {
        return new AppBar("");
    }

    @Provides
    @PerActivity
    ArrayList<String> provideTitles() {
        return new ArrayList<>();
    }

    @Provides
    @PerActivity
    ArrayList<Fragment> provideFragments() {
        return new ArrayList<>();
    }

    @Provides
    @PerActivity
    FragmentPagerAdapter provideAdapter(Activity activity, ArrayList<String> titles, ArrayList<Fragment> fragments) {
        FragmentPagerAdapter adapter = new FragmentPagerAdapter(((FragmentActivity) activity).getSupportFragmentManager(), titles, fragments);
        return adapter;
    }

    @Provides
    @PerActivity
    GoodsCategoryViewModel provideGoodsCategoryViewModel(RequestApi requestApi) {
        return new GoodsCategoryViewModel(requestApi);
    }

    @Provides
    @PerActivity
    GoodsCategorySearchViewModel provideGoodsCategorySearchViewModel(RequestApi requestApi) {
        return new GoodsCategorySearchViewModel(requestApi);
    }

    @Provides
    @PerActivity
    GoodsViewModel provideViewModel(RequestApi requestApi, RxBus rxBus) {
        return new GoodsViewModel(requestApi, rxBus);
    }
}
